<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台首页</title>
    <link rel="stylesheet" href="/php/tpblog/public/BootStrap/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/php/tpblog/public/BootStrap/css/bootstrap-rtl.css" />
    <script type="text/javascript" src="/php/tpblog/public/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="/php/tpblog/public/BootStrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/php/tpblog/public/js/layer.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse">
    <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">بىلوگ سېستىىسى </a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li <?php if(CONTROLLER_NAME == 'Index'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Index/index');?>">باشبەت <span class="sr-only">(current)</span></a></li>
                <li <?php if(CONTROLLER_NAME == 'Category'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Category/index');?>">مەزمۇن</a></li>
                <li <?php if(CONTROLLER_NAME == 'User'): ?>class="active"<?php endif; ?>><a href="<?php echo U('User/index');?>">باشقۇرغۇچىلار</a></li>
                <li <?php if(CONTROLLER_NAME == 'Navs'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Navs/index');?>">ئىقتىدار</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/php/tpblog/index.php" target="_blank">ئالدى بەت</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">ياخشىمۇسىز <?php echo ($sessions['auser']); ?><span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <?php $a_aid=$sessions['aid'] ?>
                         <li><a href="<?php echo U('User/edit',array('aid'=>$a_aid));?>">ئارخىب تەھرىرلەش</a></li>
                        <li><a href="<?php echo U('Index/logout');?>">بىخەتەر چېكىنىش </a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<div class="container">
    <div class="row">
        <div style="height: 30px"></div>
        <div class="col-md-2">
            <ul class="list-group">
    <li class="list-group-item <?php if(CONTROLLER_NAME == 'Navs'): ?>active<?php endif; ?>"><a href="<?php echo U('Navs/index');?>">تىزىملىك باشقۇرۇش</a></li>
    <li class="list-group-item <?php if(CONTROLLER_NAME == 'Sliders'): ?>active<?php endif; ?>"><a href="<?php echo U('Sliders/index');?>">چوڭ ئايلانما ئېلان باشقۇرۇش</a></li>
    <li class="list-group-item <?php if(CONTROLLER_NAME == 'Links'): ?>active<?php endif; ?>"><a href="<?php echo U('Links/index');?>">دوستانە ئۇلىنىش باشقۇرۇش</a></li>
    <li class="list-group-item <?php if(CONTROLLER_NAME == 'Configs'): ?>active<?php endif; ?>"><a href="<?php echo U('Configs/index');?>">تەڭشەك باشقۇرۇش</a></li>
</ul>
<style>
    .list-group .active a{
        color: #fff;
    }
</style>

        </div>
        <div class="col-md-10">
            <div class="page-header">
                <h4><?php echo ($page_title); ?></h4>
            </div>
            <div class="btn-group" role="group" aria-label="...">
                <a  href="<?php echo U('Navs/index');?>" type="button" class="btn btn-default">بارلىق تىزىملىكلەر</a>
                <a href="<?php echo U('Navs/add');?>" type="button" class="btn btn-default">يېڭىدىن قوشۇش</a>
            </div>
            <br><br>
            <table class="table table-bordered">
                <thead>
                <tr class="active">
                    <td width="30">ID</td>
                    <td>تەرتىب </td>
                    <td> تىزىملىك نامى</td>
                    <td width="55">ھالىتى</td>
                    <td>مەشغۇلات</td>
                </tr>
                </thead>
                <tbody>
                <?php if(is_array($navs)): foreach($navs as $key=>$n): ?><tr>
                        <td><?php echo ($n['id']); ?></td>
                        <td>
                          <input onchange="navsSort(this,<?php echo ($n['id']); ?>)" class="form-control" value="<?php echo ($n['sort']); ?>">
                        </td>
                        <td><?php echo ($n['name']); ?></td>
                        <td>
                            <?php if($n['status']): ?><span class="label label-success">ئوچۇق</span>
                                <?php else: ?>
                                <span class="label label-danger">تاقاق</span><?php endif; ?>
                        </td>
                        <td>
                            <a href="<?php echo U('Navs/edit',array('id'=>$n['id']));?>" class="btn btn-success btn-sm">تەھرىرلەش</a>
                            <a  href="javascript:deleteNavs(<?php echo ($n['id']); ?>)" class="btn btn-danger btn-sm">ئۆچۈرۈش</a>

                        </td>
                    </tr><?php endforeach; endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script type="text/javascript">
    function navsSort(obj,id) {
        var sort=$(obj).val();
        $.ajax({
            'url':"<?php echo U('Navs/navsSort');?>",
            'type':'POST',
            'dataType':'json',
            'data':{'id':id,'sort':sort},
            success:function (phpRetrnData) {
                if(phpRetrnData.status){
                    layer.msg(phpRetrnData.message,{'icon':6},function () {
                        window.location=location;
                    })
                }else {
                    layer.msg(phpRetrnData.message,{'icon':5});
                }
            }
        })
    }
    //删除提示框
    function deleteNavs(id) {
        //询问框
        layer.confirm('راستىنلا ئۆچۈرەمسىز？', {
            btn: ['ھەئە','ياق'] //按钮
        }, function(){
            $.ajax({
                'url':"<?php echo U('Navs/deleteNavs');?>",
                'type':'POST',
                'dataType':'json',
                'data':{'id':id},
                success:function (phpRetrnData) {
                    if(phpRetrnData.status){
                        layer.msg(phpRetrnData.message,{'icon':6},function () {
                            window.location=location;
                        })
                    }else {
                        layer.msg(phpRetrnData.message,{'icon':5});
                    }
                }
            })
        });
    }
</script>

</body>
</html>